#include "WOP_Char_Entry.h"
#include "MappingEngine.h"
#include "Command_Agent.h"
#include "DIVA_Manager.h"
//#include "ptvm/Color_Ball_Bool_ptvm.h"
#include "plain_lbvm.h"
//#include "ptvm/textual_value_ptvm.h"
using namespace std;

extern xMappingTree* mTree;

WOP_Char_Entry::WOP_Char_Entry(string s,WOP_Entry* parent){//被程式unfold出來的(top = false)
	init(s,parent);
}
WOP_Char_Entry::WOP_Char_Entry(string s){//user手動檢視的 (top = true)
	init(s,NULL);
}

bool WOP_Char_Entry::update(){	
	char value ;

	if(_updated)//如果已經更新，那就跳過
		return _changed;		
	Command_Agent* ca = Command_Agent::getInstance();
	assert(_name != "?");  // a wop with name "?" should not be updated. Check who call this to find bugs 
	std::string new_value = ca->getValue(_name);//向CommandAgent要求更新數值
	if (new_value != _value) {
		_value = new_value ;
		_changed = true;
	}

	if(from_string<char>(value, std::string(_value), std::boolalpha)) {
		_val = value ;
	}
	_updated = true ;
	return _changed;
}